(()=>{

    function getArr(value:number,count:number):number[] {
        const arr:number[] = []
        for(let i=0;i<count;i++){
            arr.push(value)
        }
        return arr
    }

    let arr1 = getArr(4,5)
    console.log(arr1)


    function getArr2(value:string,count:number):string[] {
        const arr:string[] = []
        for(let i=0;i<count;i++){
            arr.push(value)
        }
        return arr
    }
    let arr2 = getArr2('abc',5)
    console.log(arr2)


    // 泛型函数
    function getArr3<T>(value:T,count:number):T[] {
        const arr:T[] = []
        for(let i=0;i<count;i++){
            arr.push(value)
        }
        return arr
    }

    let arr3 = getArr3<string>('abc',5)
    console.log(arr3)
    let arr4 = getArr3<number>(5,5)
    console.log(arr4)

})()